#include <Island.hpp>


int continuity_detect_L(int& start,int& end,int& start_y,int& end_y){
    int continuity_flag_L = 0;
    int dl = sqrt((end - start)*(end - start) + (end_y - start_y)*(end_y - start_y));
    if(dl > 20 && dl < 100)continuity_flag_L = 1;
    return continuity_flag_L;
}

int continuity_detect_R(int& start,int& end,int& start_y,int& end_y){
    int continuity_flag_R = 0;
    int dr = sqrt((end - start)*(end - start) + (end_y - start_y)*(end_y - start_y));
    if(dr > 20 && dr < 100)continuity_flag_R = 1;
    return continuity_flag_R;
}

int cornor_detect_L(Mat& binary,int& start_line,int& end_line,int& mid,int& leftx){
    int flag = 0;
    int pre_flag = 0;
    int flag_max = 0;
    int flag_min = 0;
    for(int x = start_line;x < end_line;x++){
    for(int i = mid ; i > leftx ; i--){
        if(i >= 0 && i < binary.rows && mid >= 0 && mid < binary.cols){
            if(binary.at<uchar>(i,mid) == 255)flag++;
            if(binary.at<uchar>(i,mid) == 0)break;
        } else {
            break;
        }
    }
    if(flag > flag_max) flag_max = flag;
    if(flag_min == 0 || flag < flag_min) flag_min = flag;
    pre_flag = flag;
    flag = 0;
    }
    int p = flag_max - flag_min;
    if(p > 10)return 1;
    else return 0;
}